'''
Created on Apr 19, 2009

@author: Administrator
'''
from django.db import models
from django.contrib.auth.models import User

class AddressBook(models.Model):
    name = models.CharField(max_length=50, null=False)
    phone = models.CharField(max_length=30, null=False)
    email = models.EmailField(max_length=75, null=False)
    address = models.CharField(max_length=200, null=False)
    postnum = models.CharField(max_length=20, null=False)
    province = models.CharField(max_length=30, null=False)
    city = models.CharField(max_length=30, null=False)
    district = models.CharField(max_length=100, null=False)
    user = models.ForeignKey(User, null=False)
    
    def get_default_address_book(self):
        return AddressBook.objects.filter(user__id=self.user.id)[0]
